import { defineConfig, loadEnv } from 'vite'
import createPlugins from './vite/plugins'
import { resolve } from 'path'

// https://vite.dev/config/ fileURLToPath(new URL('./src', import.meta.url)),
export default defineConfig(({ mode }) => {
  const env = loadEnv(mode, process.cwd())
  return {
    base: env.VITE_APP_CONTEXT_PATH,
    plugins: createPlugins(),
    resolve: {
      alias: {
        '@': resolve(__dirname, './src')
      }
    },
    server: {
      host: '0.0.0.0',
      port: 8082
    },
    css: {
      preprocessorOptions: {
        less: {
          javascriptEnabled: true
        }
      }
    },
    define: {
      'process.env': env
    }
  }
})
